zynqmp: pm: Return the buffered PLL mode through IOCTL PLL get mode API
authorJolly Shah <[email protected]>
Wed, 2 Jan 2019 20:49:21 +0000 (12:49 -0800)
committerJolly Shah <[email protected]>
Fri, 4 Jan 2019 19:43:16 +0000 (11:43 -0800)
When linux calls pm_ioctl_get_pll_frac_mode() it doesn't expect the actual
mode to be read from hardware, but the value that it is intending to
program. Therefore, we return the buffered value to linux.

Signed-off-by: Mirela Simonovic <[email protected]>
Acked-by: Will Wong <[email protected]>
Signed-off-by: Jolly Shah <[email protected]>
plat/xilinx/zynqmp/pm_service/pm_api_clock.c
plat/xilinx/zynqmp/pm_service/pm_api_clock.h
plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c

index 8cdc0e43e30f1ecb5dd7b678d1b34483106d706d..1fab38fac63c2da3ab6a5b079620c9c2797bbd17 100644 (file)
@@ -3153,37 +3153,22 @@ enum pm_ret_status pm_clock_set_pll_mode(enum clock_id clock_id,
 }
 
 /**
- * pm_ioctl_get_pll_mode() -  Get PLL mode
- * @pll     PLL id
- * @mode    Mode fraction/integar
+ * pm_clock_get_pll_mode() -  Get PLL mode
+ * @clock_id   PLL clock id
+ * @mode       Location to store the mode (fractional/integer)
  *
- * This function returns current PLL mode.
+ * This function returns buffered PLL mode.
  *
- * @return      Returns status, either success or error+reason
+ * @return      Success if mode is stored or error if an argument is invalid
  */
-enum pm_ret_status pm_api_clk_get_pll_mode(unsigned int pll,
-                                          unsigned int *mode)
+enum pm_ret_status pm_clock_get_pll_mode(enum clock_id clock_id,
+                                        unsigned int *mode)
 {
-       enum pm_ret_status ret = PM_RET_SUCCESS;
-       unsigned int val, reg;
+       struct pm_pll *pll = pm_clock_get_pll(clock_id);
 
-       if (!pm_clock_valid(pll))
+       if (!pll || !mode)
                return PM_RET_ERROR_ARGS;
+       *mode = pll->mode;
 
-       if (pm_clock_type(pll) != CLK_TYPE_OUTPUT)
-               return PM_RET_ERROR_NOTSUPPORTED;
-
-       if (!ISPLL(pll))
-               return PM_RET_ERROR_NOTSUPPORTED;
-
-       reg = clocks[pll].control_reg + PLL_FRAC_OFFSET;
-
-       ret = pm_mmio_read(reg, &val);
-       val = val & PLL_FRAC_MODE_MASK;
-       if (val == 0)
-               *mode = PLL_INT_MODE;
-       else
-               *mode = PLL_FRAC_MODE;
-
-       return ret;
+       return PM_RET_SUCCESS;
 }
index bf42d950f82c365dd8e9c6a10b775d3f12802f83..3a70036f954c5937d38f9aa1aa4cd0d76909ddc0 100644 (file)
@@ -310,7 +310,7 @@ enum pm_ret_status pm_api_clock_getparent(unsigned int clock_id,
                                          unsigned int *parent_idx);
 enum pm_ret_status pm_clock_set_pll_mode(enum clock_id clock_id,
                                         unsigned int mode);
-enum pm_ret_status pm_api_clk_get_pll_mode(unsigned int pll,
-                                          unsigned int *mode);
+enum pm_ret_status pm_clock_get_pll_mode(enum clock_id clock_id,
+                                        unsigned int *mode);
 
 #endif /* PM_API_CLOCK_H */
index 284d9015c47efe920602ce7d7e79e79eac7ef217..3e368971b6f9c93868b6fde2ef7e76a3f108e5e6 100644 (file)
@@ -348,7 +348,7 @@ static enum pm_ret_status pm_ioctl_set_pll_frac_mode
 /**
  * pm_ioctl_get_pll_frac_mode() -  Ioctl function for
  *                                getting pll mode
- * @pll     PLL id
+ * @pll     PLL clock id
  * @mode    Mode fraction/integar
  *
  * This function return current PLL mode
@@ -358,7 +358,7 @@ static enum pm_ret_status pm_ioctl_set_pll_frac_mode
 static enum pm_ret_status pm_ioctl_get_pll_frac_mode
                        (unsigned int pll, unsigned int *mode)
 {
-       return pm_api_clk_get_pll_mode(pll, mode);
+       return pm_clock_get_pll_mode(pll, mode);
 }
 
 /**